Skip to content

Bug/inspect subcommand #124

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 5 commits into from
Jun 18, 2025
Merged

Bug/inspect subcommand #124

merged 5 commits into from
Jun 18, 2025

Conversation

agustingroh
Copy link
Contributor

@agustingroh agustingroh commented Jun 18, 2025

WHAT

Fixed

  • Fixed errors when no versions are declared in scanner results for inspect subcommand

Changed

  • Prioritized licenses by source priority in inspect copyleft subcommand

Summary by CodeRabbit

  • Bug Fixes

    • Resolved errors when no versions are declared in scanner results for the inspect subcommand. Components without versions are now handled gracefully.
  • New Features

    • The inspect copyleft subcommand now prioritizes licenses based on source priority, ensuring more consistent license filtering.
  • Chores

    • Updated version to 1.25.2.
    • Added a changelog entry for version 1.25.2 with updated comparison links.

@agustingroh agustingroh self-assigned this Jun 18, 2025
@agustingroh agustingroh added the bug Something isn't working label Jun 18, 2025
Copy link

coderabbitai bot commented Jun 18, 2025

Warning

Rate limit exceeded

@agustingroh has exceeded the limit for the number of commits or files that can be reviewed per hour. Please wait 7 minutes and 28 seconds before requesting another review.

⌛ How to resolve this issue?

After the wait time has elapsed, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

We recommend that you space out your commits to avoid hitting the rate limit.

🚦 How do rate limits work?

CodeRabbit enforces hourly rate limits for each developer per organization.

Our paid plans have higher rate limits than the trial, open-source and free plans. In all cases, we re-allow further reviews after a brief timeout.

Please see our FAQ for further information.

📥 Commits

Reviewing files that changed from the base of the PR and between 9d18193 and 1aab412.

📒 Files selected for processing (6)
  • CHANGELOG.md (2 hunks)
  • src/scanoss/__init__.py (1 hunks)
  • src/scanoss/inspection/copyleft.py (1 hunks)
  • src/scanoss/inspection/policy_check.py (5 hunks)
  • src/scanoss/inspection/undeclared_component.py (1 hunks)
  • tests/test_policy_inspect.py (5 hunks)

Walkthrough

This update introduces version 1.25.2, updating the version string and changelog. It refactors component extraction in several modules to use a centralized helper for license list conversion. The policy check logic is enhanced to handle missing data more robustly and to prioritize licenses based on their source.

Changes

File(s) Change Summary
CHANGELOG.md Added entry for version 1.25.2, describing bug fixes and new license source priority behavior.
src/scanoss/init.py Updated __version__ from '1.25.1' to '1.25.2'.
src/scanoss/inspection/policy_check.py Improved missing data handling, added license source prioritization, added _convert_components_to_list and _get_licenses_order_by_source_priority helper methods, and updated internal logic for component and license processing.
src/scanoss/inspection/copyleft.py
src/scanoss/inspection/undeclared_component.py
Refactored _get_components to use _convert_components_to_list helper for license conversion, simplifying the method bodies.
tests/test_policy_inspect.py Updated test assertions to reflect changes in component counts and simplified license strings in expected outputs.

Sequence Diagram(s)

sequenceDiagram
    participant User
    participant CLI
    participant PolicyCheck

    User->>CLI: Run 'inspect copyleft' or 'inspect policy'
    CLI->>PolicyCheck: Parse scanner results
    PolicyCheck->>PolicyCheck: _get_components_data()
    PolicyCheck->>PolicyCheck: _append_component() (with license source prioritization)
    PolicyCheck->>PolicyCheck: _convert_components_to_list()
    PolicyCheck-->>CLI: Return processed components with prioritized licenses
    CLI-->>User: Output inspection results
Loading

Possibly related PRs

  • scanoss/scanoss.py#122: Modifies _get_components_data and _append_component in policy_check.py for improved component extraction and license processing, closely related to the changes here.
  • scanoss/scanoss.py#123: Refactors _get_components in copyleft.py and undeclared_component.py and modifies license processing, directly connected to this PR’s refactoring.

Suggested reviewers

  • eeisegn

Poem

In version hops, we leap anew,
With licenses sorted, and warnings few.
Components gathered, lists made neat,
Rabbits coding, quick and fleet!
1.25.2, a tidy patch—
Bugs and chaos, no longer match.
🐇✨

✨ Finishing Touches
  • 📝 Generate Docstrings

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share
🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Explain this complex logic.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai explain this code block.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read src/utils.ts and explain its main purpose.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

Support

Need help? Create a ticket on our support page for assistance with any issues or questions.

Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments.

CodeRabbit Commands (Invoked using PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai generate docstrings to generate docstrings for this PR.
  • @coderabbitai generate sequence diagram to generate a sequence diagram of the changes in this PR.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

CodeRabbit Configuration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 2

🔭 Outside diff range comments (1)
src/scanoss/inspection/copyleft.py (1)

210-213: SUCCESS / FAIL logic reversed

run() returns FAIL when no copyleft components are found:

if len(copyleft_components) <= 0:
    return PolicyStatus.FAIL.value, results

Typically the check should succeed (SUCCESS) when no violations exist and fail only when copyleft components are present.

-        if len(copyleft_components) <= 0:
-            return PolicyStatus.FAIL.value, results
-        return PolicyStatus.SUCCESS.value, results
+        if len(copyleft_components) > 0:
+            return PolicyStatus.FAIL.value, results
+        return PolicyStatus.SUCCESS.value, results
🧹 Nitpick comments (4)
CHANGELOG.md (1)

12-17: Changelog entry OK – minor nit

Consider adding a short “### Security” (even if empty) for consistency with older releases.

src/scanoss/inspection/copyleft.py (1)

64-68: Avoid shadowing the built-in format function

self.format = format overwrites Python’s built-in format.
Rename the attribute (e.g. format_type) to prevent confusion and future bugs.

src/scanoss/inspection/undeclared_component.py (1)

64-66: Same built-in shadowing as in copyleft module

self.format = format masks the built-in format. Rename to format_type for clarity.

src/scanoss/inspection/policy_check.py (1)

441-480: License-priority helper – minor efficiency / style notes

  1. Converting licenses_by_source to dict[str, dict] then back to list duplicates memory; iterate once and return when first priority hit to save work.
  2. Missing space after comma in the signature: def _get_licenses_order_by_source_priority(self, licenses_data):
📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 7e19648 and ff60025.

📒 Files selected for processing (5)
  • CHANGELOG.md (2 hunks)
  • src/scanoss/__init__.py (1 hunks)
  • src/scanoss/inspection/copyleft.py (1 hunks)
  • src/scanoss/inspection/policy_check.py (4 hunks)
  • src/scanoss/inspection/undeclared_component.py (1 hunks)
🧰 Additional context used
🪛 LanguageTool
CHANGELOG.md

[duplication] ~13-~13: Possible typo: you repeated a word.
Context: ...hanges... ## [1.25.2] - 2025-06-18 ### Fixed - Fixed errors when no versions are declared in...

(ENGLISH_WORD_REPEAT_RULE)

⏰ Context from checks skipped due to timeout of 90000ms (1)
  • GitHub Check: build
🔇 Additional comments (2)
src/scanoss/__init__.py (1)

25-25: Version bump looks good

Nothing else to flag here.

src/scanoss/inspection/undeclared_component.py (1)

257-257: Good reuse of shared helper

Switching to _convert_components_to_list keeps logic consistent across inspectors.

@agustingroh agustingroh force-pushed the bug/inspect-subcommand branch from 476c8b1 to 9d18193 Compare June 18, 2025 14:45
Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 0

♻️ Duplicate comments (1)
tests/test_policy_inspect.py (1)

257-262: Duplicate check – same fragility comment as above

See the previous note: relying on exact whitespace makes the test noisy for benign formatting tweaks. A small helper that normalises markdown rows would keep maintenance cost low.

🧹 Nitpick comments (4)
tests/test_policy_inspect.py (4)

117-118: Hard-coding the new expected size may hide future regressions

The update from 32 components appears correct given the refactor, but the assertion is still a magic number.
Consider asserting against the length of results['summary'].split() or explicitly checking the purls you expect to survive the new prioritisation – this future-proofs the test if another priority tweak changes the count again.


150-155: Brittle comparison due to literal newline character

expected_summary_output ends with a trailing \n. On Windows or when refactoring the formatter this may flip to \r\n, causing a false-negative.
Prefer stripping line endings before the equality check:

-expected_summary_output = '2 component(s) with copyleft licenses were found.\n'
+expected_summary_output = '2 component(s) with copyleft licenses were found.'
 ...
-self.assertEqual(results['summary'], expected_summary_output)
+self.assertEqual(results['summary'].strip(), expected_summary_output)

214-219: String-equality on Markdown table rows is fragile

The test will fail if column order or spacing changes even though the semantic information is identical.
Instead of literal equality, parse the markdown (or simply split the line on |) and assert on the tuple (purl, version, license) for each row.


333-337: Jira-MD expectations suffer from the same brittleness

Literal pipe-separated strings are prone to break when the renderer changes alignment. Consider tokenising the line and asserting on the fields, or at least normalising whitespace.

📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between ff60025 and 9d18193.

📒 Files selected for processing (1)
  • tests/test_policy_inspect.py (5 hunks)
⏰ Context from checks skipped due to timeout of 90000ms (1)
  • GitHub Check: build

@agustingroh agustingroh force-pushed the bug/inspect-subcommand branch from 9d18193 to 1aab412 Compare June 18, 2025 14:56
@agustingroh agustingroh requested a review from eeisegn June 18, 2025 15:02
@agustingroh agustingroh merged commit 02f0092 into main Jun 18, 2025
4 checks passed
@agustingroh agustingroh deleted the bug/inspect-subcommand branch June 18, 2025 15:04
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants